- expanded = integration_expanded?('error_tracking_')

= render ::Layouts::SettingsBlockComponent.new(_('GitLab Error Tracking'),
  id: 'js-error-tracking-settings',
  expanded: expanded) do |c|
  - c.with_description do
    = _('Allows projects to track errors using an Opstrace integration.').html_safe % { link: help_page_path('operations/error_tracking.md') }
    = link_to _('Learn more.'), help_page_path('operations/error_tracking.md'), target: '_blank', rel: 'noopener noreferrer'
  - c.with_body do
    %fieldset
      .sub-section
        %h4= _('Access Token')
        .form-group
          .form-text
            %p.gl-text-subtle
              = s_("ErrorTracking|Access token is %{token_in_code_tag}").html_safe % { token_in_code_tag: content_tag(:code, Gitlab::CurrentSettings.error_tracking_access_token, id: 'error-tracking-access-token') }
          .form-inline
            - reset_url = reset_error_tracking_access_token_admin_application_settings_url
            = render Pajamas::ButtonComponent.new(method: :put, href: reset_url, variant: :danger, size: :small, button_options: { data: { confirm: _('Are you sure you want to reset the error tracking access token?') }}) do
              = _("Reset error tracking access token")

    = gitlab_ui_form_for @application_setting, url: general_admin_application_settings_path(anchor: 'js-error-tracking-settings'), html: { class: 'fieldset-form', id: 'error-tracking-settings' } do |f|
      = form_errors(@application_setting) if expanded

      %fieldset
        .sub-section
          %h4= _('Configure Error Tracking')
          .form-group
            = f.gitlab_ui_checkbox_component :error_tracking_enabled,
            _('Enable GitLab Error Tracking')
          .form-group
            = f.label :error_tracking_api_url, _('Opstrace endpoint for Error Tracking integration'), class: 'label-light'
            = f.text_field :error_tracking_api_url, class: 'form-control gl-form-input'

      = f.submit _('Save changes'), pajamas_button: true
